//
//  ListTypeRequirementViewController.m
//  FMS
//
//  Created by Steven on 10/12/13.
//  Copyright (c) 2013 QGSVN. All rights reserved.
//

#import "ListTypeRequirementViewController.h"

@interface ListTypeRequirementViewController ()

@end

@implementation ListTypeRequirementViewController
@synthesize delegate;

- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
        dictLanguage = [ApplicationDelegate.arrayLanguage objectAtIndex:0];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self setContentSizeForViewInPopover:CGSizeMake(320, 320)];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{

    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
        cell.textLabel.font = [UIFont fontWithName:FMS_REGULAR_FONT size:15];
        cell.textLabel.textColor = FMS_COLOR_DEFAUL;

    }
    if (indexPath.row == 0)
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    else
        cell.selectionStyle = UITableViewCellSelectionStyleGray;
    switch (indexPath.row) {
        case 0:
            cell.textLabel.text = [dictLanguage objectForKey:@"schedule.title-select"];
            break;
        case 1:
            cell.textLabel.text = [dictLanguage objectForKey:@"schedule.title-monthly"];
            break;
        case 2:
            cell.textLabel.text = [dictLanguage objectForKey:@"schedule.title-quaterly"];
            break;
        case 3:
            cell.textLabel.text = [dictLanguage objectForKey:@"schedule.title-yearly"];
            break;
        case 4:
            cell.textLabel.text = [dictLanguage objectForKey:@"schedule.title-other"];
            break;
        default:
            break;
    }
    // Configure the cell...
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0)
        return;
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    if ([delegate respondsToSelector:@selector(didSelectTypeRequirement:)]) {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
        
        NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInteger:indexPath.row],@"requirementType",cell.textLabel.text,@"requirementName", nil];
        [delegate didSelectTypeRequirement:dict];
    }
}
@end
